<?php
/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 14/11/18
 * Time: 下午11:58
 */

class PlatformGameMapService extends Service {

    public static function getMap(){
        $modPlatformGameMap = new ModPlatformGameMap();
        $tmp    = $modPlatformGameMap->select();
        $result = array();

        foreach($tmp as $v){
            $result[$v['PlatformID']][] = $v['GameID'];
        }
        return $result;
    }

    public static function getGameByPlatform($platformId){

        $modPlatformGameMap = new ModPlatformGameMap();

        $tmp = $modPlatformGameMap->select(array('platform' => $platformId));

        $result = array();

        foreach($tmp as $v){
            $result[] = $v['GameID'];
        }

        return $result;
    }

    public static function getPlatformByGame($gameId){

        $modPlatformGameMap = new ModPlatformGameMap();

        $tmp = $modPlatformGameMap->select(array('game' => $gameId));

        $result = array();

        foreach($tmp as $v){
            $result[] = $v['PlatformID'];
        }

        return $result;
    }

} 